<?php
namespace App\Models\Client;
use App\Models\AgentUser\AgentUserModel;
use App\Models\BaseAuthModel;
use App\Models\Team\TeamModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * C端用户模型
 * @property int $id
 * @property int|null $agent_id 服务商id
 * @property int|null $wechat_user_id 微信用户id
 * @property string|null $country_code 国家代码
 * @property string|null $mobile 国家代码
 * @property string|null $nickname 用户昵称
 * @property string|null $avatar 头像
 * @property int|null $is_vip
 * @property string|null $vip_expired vip到期时间
 * @property string|null $status 状态
 * @property string|null $channel 渠道
 * @property string|null $info_ready 是否完善信息
 * @property string|null $remark 备注
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property \Illuminate\Support\Carbon|null $deleted_at
 */
class ClientUserModel extends BaseAuthModel
{
    use HasFactory,SoftDeletes;

    protected $table = 'client_users';

    protected $guarded = [];

    protected $hidden = ['updated_at', 'deleted_at'];

    const STATUS_NORMAL = 'normal'; //正常
    const STATUS_FORBIDDEN = 'forbidden'; //禁用


    //============模型枚举常量定义===========

    public function agent(){
        return $this->belongsTo(AgentUserModel::class, 'id', 'agent_id');
    }

    public function team(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
    {
        return $this->belongsToMany(TeamModel::class,'team_users','team_user_id','team_id');
    }
}
